package com.zzyl.mapper;

import com.zzyl.entity.Resource;
import com.zzyl.vo.ResourceVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RecursionMapper {
    List<ResourceVo> list(ResourceVo resourceVo);

    @Select("SELECT * FROM sys_resource where resource_no = #{parent_resource_no}")
    Resource selectByParentNo(String parentResourceNo);

    @Select("select max(resource_no) from sys_resource where parent_resource_no = #{parentResourceNo}")
    String getMaxResourceNo(String parentResourceNo);

    void insert(Resource resource);


    void update(Resource resource);

    @Select("select * from sys_resource where resource_no = #{resourceNo}")
    Resource selectByResourceNo(String parentResourceNo);

    @Update("update sys_resource set data_state = #{dataState} where resource_no = #{resourceNo} ")
    void updateByResourceNo(@Param("resourceNo") String resourceNo, @Param("dataState") String dataState);

    @Update("update sys_resource set data_state = #{dataState} where parent_resource_no like concat(#{resourceNo},'%')")
    void updateByParentResourceNo(@Param("resourceNo")String resourceNo,@Param("dataState") String dataState);

    @Select("select count(1) from sys_resource where parent_resource_no = #{resourceNo}")
    int childCount(String resourceNo);

    @Delete("delete from sys_resource where resource_no = #{resourceNo}")
    void deleteByResourceNo(String resourceNo);
}
